home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / OS / FWGraphx / Sources / FWPicShp.cpp < prev    next >
Encoding:
Text File  |  1994-04-21  |  8.1 KB  |  287 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWPicShp.cpp
  4. //    Release Version:    $ 1.0d1 $
  5. //
  6. //    Creation Date:        4/12/94
  7. //
  8. //    Copyright:    © 1993, 1994 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef FWPICSHP_H
  13. #include "FWPicShp.h"
  14. #endif
  15.  
  16. #ifndef FWGC_H
  17. #include "FWGC.h"
  18. #endif
  19.  
  20. #ifndef FWDFAULT_H
  21. #include "FWDfault.h"
  22. #endif
  23.  
  24. #ifndef FWBMPSHP_H
  25. #include "FWBmpShp.h"
  26. #endif
  27.  
  28. #ifndef FWPRIBEB_H
  29. #include "FWPriDeb.h"
  30. #endif
  31. // ----- OpenDoc Includes -----
  32.  
  33. #ifndef _TRNSFORM_
  34. #include <Trnsform.h>
  35. #endif
  36.  
  37. //==============================================================================
  38. //    •• RunTime Info
  39. //==============================================================================
  40.  
  41. #ifdef FW_BUILD_MAC
  42. #pragma segment fwgraphx
  43. #endif
  44.  
  45. //==============================================================================
  46. //    •• class FW_CPictShape
  47. //==============================================================================
  48.  
  49. //------------------------------------------------------------------------------
  50. // FW_CPictShape::FW_CPictShape
  51. //------------------------------------------------------------------------------
  52.  
  53. FW_CPictShape::FW_CPictShape() :
  54.     FW_CShape()
  55. {
  56. }
  57.  
  58. //------------------------------------------------------------------------------
  59. // FW_CPictShape::FW_CPictShape
  60. //------------------------------------------------------------------------------
  61.  
  62. FW_CPictShape::FW_CPictShape(FW_PlatformPict platformPict) :
  63.     FW_CShape()
  64. {
  65. #ifdef FW_BUILD_MAC
  66.     FW_CRect rect = (*platformPict)->picFrame;
  67.     rect.Place(0, 0);
  68. #endif
  69.  
  70. #ifdef FW_BUILD_WIN
  71.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  72. #endif
  73.  
  74.     SetRep(new FW_CPictShapeRep(platformPict, rect));
  75. }
  76.  
  77. //------------------------------------------------------------------------------
  78. // FW_CPictShape::FW_CPictShape
  79. //------------------------------------------------------------------------------
  80.  
  81. FW_CPictShape::FW_CPictShape(FW_PlatformPict platformPict, const FW_CRect& rect) :
  82.     FW_CShape()
  83. {
  84.     SetRep(new FW_CPictShapeRep(platformPict, rect));
  85. }
  86.  
  87. //------------------------------------------------------------------------------
  88. // FW_CPictShape::FW_CPictShape
  89. //------------------------------------------------------------------------------
  90.  
  91. FW_CPictShape::FW_CPictShape(FW_CPictShapeRep* other) :
  92.     FW_CShape(other)
  93. {
  94. }
  95.  
  96. //------------------------------------------------------------------------------
  97. // FW_CPictShape::FW_CPictShape
  98. //------------------------------------------------------------------------------
  99.  
  100. FW_CPictShape::FW_CPictShape(const FW_CPictShape& other) :
  101.     FW_CShape() // the compiler refuse to take FW_CShape(other) ?????
  102. {
  103.     SetRep(other.GetRep());
  104. }
  105.  
  106. //------------------------------------------------------------------------------
  107. // FW_CPictShape::operator=
  108. //------------------------------------------------------------------------------
  109.  
  110. FW_CPictShape& FW_CPictShape::operator=(const FW_CPictShape& other)
  111. {
  112.     SetRep(other.GetRep());
  113.     return *this;
  114. }
  115.  
  116. //------------------------------------------------------------------------------
  117. // FW_CPictShape::operator=
  118. //------------------------------------------------------------------------------
  119.  
  120. FW_CPictShape& FW_CPictShape::operator=(FW_CPictShapeRep* other)
  121. {
  122.     SetRep(other);
  123.     return *this;
  124. }
  125.  
  126. //------------------------------------------------------------------------------
  127. // FW_CPictShape::operator FW_CBitmapShape
  128. //------------------------------------------------------------------------------
  129.  
  130. FW_CPictShape::operator FW_CBitmapShape() const
  131. {
  132.     FW_CBitmapShape bitmap(((FW_CPictShapeRep*)GetRep())->GetPlatformPict(), 
  133.                             ((FW_CPictShapeRep*)GetRep())->GetRectangle());
  134.     return bitmap;
  135. }
  136.  
  137. //==============================================================================
  138. //    •• class FW_CPictShapeRep
  139. //==============================================================================
  140.  
  141. //------------------------------------------------------------------------------
  142. //    • FW_CPictShapeRep::FW_CPictShapeRep
  143. //------------------------------------------------------------------------------
  144.  
  145. FW_CPictShapeRep::FW_CPictShapeRep() :
  146.     FW_CBoundedShapeRep(gGraphicGlobales.gPicture, FW_CRect(0,0,0,0)),
  147.     fPlatformPict(NULL)
  148. {
  149. }
  150.  
  151. //------------------------------------------------------------------------------
  152. //    • FW_CPictShapeRep::FW_CPictShapeRep
  153. //------------------------------------------------------------------------------
  154.  
  155. FW_CPictShapeRep::FW_CPictShapeRep(FW_PlatformPict platformPict, const FW_CRect& rect) :
  156.     FW_CBoundedShapeRep(gGraphicGlobales.gPicture, rect),
  157.     fPlatformPict(platformPict)
  158. {
  159. }
  160.  
  161. //------------------------------------------------------------------------------
  162. //    • FW_CPictShapeRep::~FW_CPictShapeRep
  163. //------------------------------------------------------------------------------
  164.  
  165. FW_CPictShapeRep::~FW_CPictShapeRep()
  166. {
  167. #ifdef FW_BUILD_MAC
  168.     if (fPlatformPict)
  169.         ::KillPicture(fPlatformPict);
  170.     fPlatformPict = NULL;
  171. #endif
  172.  
  173. #ifdef FW_BUILD_WIN
  174.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  175. #endif
  176. }
  177.  
  178. //------------------------------------------------------------------------------
  179. //    • FW_CPictShapeRep::Draw
  180. //------------------------------------------------------------------------------
  181.  
  182. void FW_CPictShapeRep::Draw(FW_CGraphicContext* graphicContext)
  183. {    
  184.     FW_ShapeFills shapeFill = GetShapeFill();
  185.     
  186.     if (fPlatformPict == NULL || shapeFill == FW_kNullShape)
  187.         return;
  188.         
  189.     FW_SPlatformRect rect = graphicContext->AsPlatformRect(fRect);
  190.  
  191. #ifdef FW_BUILD_MAC
  192.     ::DrawPicture(fPlatformPict, &rect);
  193. #endif
  194.  
  195. #ifdef FW_BUILD_WIN
  196.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  197. #endif
  198. }
  199.  
  200. //------------------------------------------------------------------------------
  201. //    • FW_CPictShapeRep::SetAsDefault
  202. //------------------------------------------------------------------------------
  203.  
  204. void FW_CPictShapeRep::SetAsDefault() const
  205. {
  206.     SetDefaultProperties(gGraphicGlobales.gPicture);
  207. }
  208.  
  209. //------------------------------------------------------------------------------
  210. //    • FW_CPictShapeRep::HitTest
  211. //------------------------------------------------------------------------------
  212.  
  213. FW_HitTestPart FW_CPictShapeRep::HitTest(const FW_CPoint& test) const
  214. {
  215.     return FW_kOutside;
  216. }
  217.  
  218. //------------------------------------------------------------------------------
  219. //    • FW_CPictShapeRep::SetPlatformPict
  220. //------------------------------------------------------------------------------
  221.  
  222. void FW_CPictShapeRep::SetPlatformPict(FW_PlatformPict platformPict)
  223. {
  224.     if (fPlatformPict)
  225. #ifdef FW_BUILD_MAC
  226.         ::KillPicture(fPlatformPict);
  227. #endif
  228. #ifdef FW_BUILD_WIN
  229. #endif
  230.     fPlatformPict = platformPict;
  231.     Changed();
  232. }    
  233.  
  234. //------------------------------------------------------------------------------
  235. //    • FW_CPictShapeRep::Flatten
  236. //------------------------------------------------------------------------------
  237.  
  238. void FW_CPictShapeRep::Flatten(FW_CWritableStream& stream)
  239. {
  240.     FW_CBoundedShapeRep::Flatten(stream);
  241.  
  242. #ifdef FW_BUILD_MAC
  243.     // ATTENTION: Temporary Code
  244.     long picSize = ::GetHandleSize((Handle)fPlatformPict);
  245.     stream << picSize;;
  246.     ::HLock((Handle)fPlatformPict);
  247.     stream.Write(*fPlatformPict, picSize);
  248.     ::HUnlock((Handle)fPlatformPict);
  249. #endif    
  250. #ifdef FW_BUILD_WIN
  251. #endif
  252. }
  253.  
  254. //------------------------------------------------------------------------------
  255. //    • FW_CPictShapeRep::Unflatten
  256. //------------------------------------------------------------------------------
  257.  
  258. void FW_CPictShapeRep::Unflatten(FW_CReadableStream& stream)
  259. {
  260.     FW_CBoundedShapeRep::Unflatten(stream);
  261.  
  262. #ifdef FW_BUILD_MAC
  263.     // ATTENTION: Temporary Code
  264.     long picSize;
  265.     stream >> picSize;
  266.     if (fPlatformPict)
  267.         ::KillPicture(fPlatformPict);
  268.     fPlatformPict = (FW_PlatformPict)::NewHandle(picSize);
  269.     ::HLock((Handle)fPlatformPict);
  270.     stream.Read(*fPlatformPict, picSize);
  271.     ::HUnlock((Handle)fPlatformPict);
  272. #endif    
  273. #ifdef FW_BUILD_WIN
  274. #endif
  275. }
  276.  
  277. //------------------------------------------------------------------------------
  278. //    • FW_CPictShapeRep::Copy
  279. //------------------------------------------------------------------------------
  280.  
  281. FW_CPictShape FW_CPictShapeRep::Copy() const
  282. {
  283.     FW_DEBUG_MESSAGE("Not Yet Implemented");
  284.     FW_CPictShape pictShape;
  285.     return pictShape;
  286. }
  287.